﻿//+------------------------------------------------------------------+
//|                                             MetaTrader 5 Web API |
//|                   Copyright 2001-2015, MetaQuotes Software Corp. |
//|                                        http://www.metaquotes.net |
//+------------------------------------------------------------------+
namespace MetaQuotes.MT5WebAPI.Common
  {
  public class MTDeal
    {
    /// <summary>
    /// Common deal flags
    /// </summary>
    public enum EnDealFlags : uint
      {
      DEAL_FLAGS_NONE = 0x00000000,
      DEAL_FLAGS_ROLLOVER = 0x00000001,
      DEAL_FLAGS_VMARGIN = 0x00000002,
      //--- enumeration borders
      DEAL_FLAGS_ALL = DEAL_FLAGS_ROLLOVER | DEAL_FLAGS_VMARGIN
      };
    /// <summary>
    /// Action deal
    /// </summary>
    public enum EnDealAction : uint
      {
      DEAL_BUY = 0,               // buy
      DEAL_SELL = 1,               // sell
      DEAL_BALANCE = 2,               // deposit operation
      DEAL_CREDIT = 3,               // credit operation
      DEAL_CHARGE = 4,               // additional charges
      DEAL_CORRECTION = 5,               // correction deals
      DEAL_BONUS = 6,               // bouns
      DEAL_COMMISSION = 7,               // commission
      DEAL_COMMISSION_DAILY = 8,               // daily commission
      DEAL_COMMISSION_MONTHLY = 9,               // monthly commission
      DEAL_AGENT_DAILY = 10,              // daily agent commission
      DEAL_AGENT_MONTHLY = 11,              // monthly agent commission
      DEAL_INTERESTRATE = 12,              // interest rate charges
      //--- enumeration borders
      DEAL_FIRST = DEAL_BUY,
      DEAL_LAST = DEAL_INTERESTRATE
      };
    /// <summary>
    /// deal entry direction
    /// </summary>
    public enum EnEntryFlags : uint
      {
      ENTRY_IN = 0,               // in market
      ENTRY_OUT = 1,               // out of market
      ENTRY_INOUT = 2,               // reverse
      //--- enumeration borders
      ENTRY_FIRST = ENTRY_IN,
      ENTRY_LAST = ENTRY_INOUT
      };
    /// <summary>
    /// deal ticket
    /// </summary>
    public ulong Deal { get; set; }
    /// <summary>
    /// deal ticket in external system (exchange, ECN, etc)
    /// </summary>
    public string ExternalID { get; set; }
    /// <summary>
    /// client login
    /// </summary>
    public ulong Login { get; set; }
    /// <summary>
    /// processed dealer login (0-means auto)
    /// </summary>
    public ulong Dealer { get; set; }
    /// <summary>
    /// deal order ticket
    /// </summary>
    public ulong Order { get; set; }
    /// <summary>
    /// EnDealAction
    /// </summary>
    public EnDealAction Action { get; set; }
    /// <summary>
    /// EnEntryFlags
    /// </summary>
    public EnEntryFlags Entry { get; set; }
    /// <summary>
    /// price digits
    /// </summary>
    public uint Digits { get; set; }
    /// <summary>
    /// currency digits
    /// </summary>
    public uint DigitsCurrency { get; set; }
    /// <summary>
    /// symbol contract size
    /// </summary>
    public double ContractSize { get; set; }
    /// <summary>
    /// deal creation datetime
    /// </summary>
    public long Time { get; set; }
    /// <summary>
    /// deal symbol
    /// </summary>
    public string Symbol { get; set; }
    /// <summary>
    /// deal price
    /// </summary>
    public double Price { get; set; }
    /// <summary>
    /// deal volume
    /// </summary>
    public ulong Volume { get; set; }
    /// <summary>
    /// deal profit
    /// </summary>
    public double Profit { get; set; }
    /// <summary>
    /// deal collected swaps
    /// </summary>
    public double Storage { get; set; }
    /// <summary>
    /// deal commission
    /// </summary>
    public double Commission { get; set; }
    /// <summary>
    /// deal agent commission
    /// </summary>
    public double CommissionAgent { get; set; }
    /// <summary>
    /// profit conversion rate (from symbol profit currency to deposit currency)
    /// </summary>
    public double RateProfit { get; set; }
    /// <summary>
    /// margin conversion rate (from symbol margin currency to deposit currency)
    /// </summary>
    public double RateMargin { get; set; }
    /// <summary>
    /// expert id (filled by expert advisor)
    /// </summary>
    public ulong ExpertID { get; set; }
    /// <summary>
    /// expert position id (filled by expert advisor)
    /// </summary>
    public ulong ExpertPositionID { get; set; }
    /// <summary>
    /// deal comment
    /// </summary>
    public string Comment { get; set; }
    /// <summary>
    /// deal profit in symbol's profit currency
    /// </summary>
    public double ProfitRaw { get; set; }
    /// <summary>
    /// closed position  price
    /// </summary>
    public double PricePosition { get; set; }
    /// <summary>
    /// closed volume
    /// </summary>
    public ulong VolumeClosed { get; set; }
    /// <summary>
    /// tick value
    /// </summary>
    public double TickValue { get; set; }
    /// <summary>
    /// tick size
    /// </summary>
    public double TickSize { get; set; }
    /// <summary>
    /// flags
    /// </summary>
    public ulong Flags { get; set; }
    }
  }
